package prototype

import "fmt"

// CustomProductCard 自定义商品卡片
type CustomProductCard struct {
	baseCard    *BaseProductCard
	customStyle string
}

// NewCustomProductCard 创建自定义商品卡片
func NewCustomProductCard(baseCard *BaseProductCard, customStyle string) *CustomProductCard {
	return &CustomProductCard{
		baseCard:    baseCard,
		customStyle: customStyle,
	}
}

// Clone 复制自定义卡片
func (c *CustomProductCard) Clone() ProductCard {
	clone := &CustomProductCard{
		baseCard:    c.baseCard.Clone().(*BaseProductCard),
		customStyle: c.customStyle,
	}
	return clone
}

// Render 渲染自定义卡片内容
func (c *CustomProductCard) Render() string {
	baseHTML := c.baseCard.Render()
	if c.customStyle != "" {
		return fmt.Sprintf("<div style='%s'>\n%s\n</div>", c.customStyle, baseHTML)
	}
	return baseHTML
}

// SetTags 设置个性化标签
func (c *CustomProductCard) SetTags(tags []string) {
	c.baseCard.SetTags(tags)
}

// SetReason 设置个性化推荐理由
func (c *CustomProductCard) SetReason(reason string) {
	c.baseCard.SetReason(reason)
}

// SetPromotion 设置个性化促销信息
func (c *CustomProductCard) SetPromotion(promotion string) {
	c.baseCard.SetPromotion(promotion)
}
